package com.fpt.mockproject.j21.absd.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NaturalId;

@Entity
@Table(name = "SERVICE_GROUP")
@DynamicUpdate(value = true)
public class ServiceGroup {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ServiceGroupID", nullable = false, updatable = false, unique = true)
	private Long serviceID;
	
	@NaturalId
	@Column(name = "ServiceGroupName", nullable = false, unique = true)
	private String serviceGroupName;
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "serviceGroup")
	private Set<PostCode> postCodes = new HashSet<>(0);
	
	public Set<PostCode> getPostCodes() {
		return postCodes;
	}
	public void setPostCodes(Set<PostCode> postCodes) {
		this.postCodes = postCodes;
	}
	public String getServiceGroupName() {
		return serviceGroupName;
	}
	public void setServiceGroupName(String serviceGroupName) {
		this.serviceGroupName = serviceGroupName;
	}
	public Long getServiceID() {
		return serviceID;
	}
	public void setServiceID(Long serviceID) {
		this.serviceID = serviceID;
	}
}
